﻿using DayuCode.Designer.Entity;
using DayuCode.Designer.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DayuCode.Designer.Service
{
    public class CodeTemplateHandler
    {
        private static string getBaseUrl(string methodName)
        {
            return AppInstance.ApiServer + "api/base/dayucode_codeTemplateHandler/" + methodName;
        }

		public static List<CodeTemplate> getCodeTemplatesByLayout(long layoutId)
		{
			List<CodeTemplate> obj = QHttpClient.Post<List<CodeTemplate>>(getBaseUrl("getCodeTemplatesByLayout"), new { layoutId = layoutId });
			return obj;
		}

		public static CodeTemplate getCodeTemplate(long? id)
		{
			CodeTemplate obj = QHttpClient.Post<CodeTemplate>(getBaseUrl("getCodeTemplate"), new { id = id });
			return obj;
		}

		public static void deleteCodeTemplate(long id)
		{
			QHttpClient.Execute(getBaseUrl("deleteCodeTemplate"), new { id = id });
		}

		public static CodeTemplate saveCodeTemplate(CodeTemplate item)
		{
			CodeTemplate obj = QHttpClient.Post<CodeTemplate>(getBaseUrl("saveCodeTemplate"), new { item = item });
			return obj;
		}
	}
}
